import { createRouter, createWebHistory } from 'vue-router'

const router = createRouter({
    history: createWebHistory(),
    routes: [
        {
            path: '/',
            redirect: '/index/home'
        },
        {
            path: '/',
            name: 'index',
            component: () => import('../views/index.vue'),
            children: [
                {
                    path: '/index/home',
                    name: 'home',
                    component: () => import('../views/home.vue'),
                },
                {
                    path: '/index/Task',
                    name: 'Task',
                    component: () => import('../views/Task.vue'),
                },
                {
                    path: '/index/TaskData',
                    name: 'TaskData',
                    component: () => import('../views/TaskData.vue'),
                },
                {
                    path: '/index/account',
                    name: 'account',
                    component: () => import('../views/account.vue'),
                }
            ]
        },
        {
            path: '/thisData',
            name: 'thisData',
            component: () => import('../views/thisData.vue'),
        },
        {
            path: '/alipayStatus',
            name: 'alipayStatus',
            component: () => import('../views/alipayStatus.vue'),
        },
        {
            path: '/FBalipay',
            name: 'FBalipay',
            component: () => import('../views/FBalipay.vue'),
        },
        {
            path: '/myReleases',
            name: 'myReleases',
            component: () => import('@/components/pc/myReleases.vue'),
        },
        {
            path: '/myList',
            name: 'myList',
            component: () => import('@/components/pc/myList.vue'),
        },
        {
            path: '/reg',
            name: 'reg',
            redirect:{name: 'userMailData'},
            component: () => import('@/components/pc/reg.vue'),
            children: [
                {
                    path: '/reg/userMailData',
                    name: 'userMailData',
                    component: () => import('@/components/pc/MailData/userMailData.vue')
                },
                {
                    path: '/reg/userMailCode',
                    name: 'userMailCode',
                    component: () => import('@/components/pc/MailData/userMailCode.vue')
                },
                {
                    path: '/reg/goHome',
                    name: 'goHome',
                    component: () => import('@/components/pc/MailData/goHome.vue')
                },
            ]
        },
        
    ],
    scrollBehavior(to, from, savedPosition) {
        if (savedPosition) {
            return savedPosition; // 如果保存了滚动位置，则恢复它  
        } else {
            return { top: 0 }; // 否则，滚动到页面顶部  
        }
    },
})

export default router